fix: grep pattern fixed to remove line comments#311
fix: grep pattern fixed to remove line comments#311langbein-daniel wants to merge 3 commits intopelias:masterfrom
Conversation
Running `pelias` yields the error `grep: warning: stray \ before #`. This can be fixed by not escaping `#` in the grep pattern.
The second part of the grep pattern does now remove lines starting with 0 or more whitespace characters followed by #.
|
Thanks for the bugfix. I don't see this warning on my terminal, could you please post the following: uname -a
Darwin Peters-MacBook-Pro-2.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64 i386 Darwin
grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSDI wonder if we can use this pattern which seems much easier to read: grep -Ev '^$|^#' .envor maybe this to maintain backwards compatibility: grep -v '^\s*[$#]' .envAlso wondering why the pipe still needs to be escaped |
|
I don't have a link to the doc handy right now, but the echo '
#
bar' | grep -v '^$\|^\s*#'The pattern I'm using Arch Linux, the exact versions are: |
|
As we have the comment Apart from that, |
|
One last thing: We are currently removing blank lines as well as lines having
Inside So, all cases are covered. But I think it would be good to document this a bit better. |
One subshell `(...) &&` was replaced with `if [...]; then`.
👋 I did some awesome work for the Pelias project and would love for everyone to have a look at it and provide feedback.
Here's the reason for this change 🚀
peliasyields the errorgrep: warning: stray \ before #.Here's what actually got changed 👏
#in the grep pattern.$after a pattern for white-spaces\s*before the line-comment character#. This was changed to^\s*#which remove lines starting with 0 or more whitespace characters followed by#.Here's how others can test the changes 👀
Run the
peliascommand and check if loading .env variables does still work as expected/is now fixed. Especially if line comments (with and without whitespace before#) get removed.